home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00378_MultiIndex Manager.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  8.3 KB  |  329 lines

  1. property iCurrIndexFileName, iCurrentPointList, iCurrentItem, iLimitsList, iMasterIndex, iMaxItems, iSizeIndex
  2. global gModeState, gAlphaState, gLocalStepCount, gGlobalStepCount, gFirstYearK, gLastYearK, gFTsearchscope, gNumofHits, gStatusField, gNopeSND, gCurrentEntryName
  3.  
  4. on birth me
  5.   set iSizeIndex to [:]
  6.   sort(iSizeIndex)
  7.   addProp(iSizeIndex, #ENCY, value(field "ENCY_ScrollPoints"))
  8.   addProp(iSizeIndex, #FoundSet, 1)
  9.   if not objectp(iSizeIndex) then
  10.   end if
  11.   set iCurrentItem to 1
  12.   set iLimitsList to [:]
  13.   sort(iLimitsList)
  14.   addProp(iLimitsList, #ENCY, mComputeModesLastEntryNum(me, #ENCY))
  15.   addProp(iLimitsList, #FoundSet, 0)
  16.   mInitMasterIndex(me)
  17.   mUpdateIndexParams(me)
  18.   return me
  19. end
  20.  
  21. on mGetSingleModeSize me, pWhat
  22.   set Llist to value(field ("ATTRIB_A_" & string(pWhat)))
  23.   return count(Llist)
  24. end
  25.  
  26. on mInitMasterIndex me
  27.   set iMasterIndex to [:]
  28.   sort(iMasterIndex)
  29.   addProp(iMasterIndex, #FoundSet, [0])
  30.   addProp(iMasterIndex, #ENCY, [0])
  31.   set iMaxItems to [#FoundSet: 1, #Resources: 1, #TOPICS: 1, #EPISSUB: 5, #ENCY: 26, #EPIS: 26, #CHRO: gLastYearK]
  32.   mClearThisModesIndex(me, #FoundSet)
  33.   mClearThisModesIndex(me, #ENCY)
  34. end
  35.  
  36. on mClearThisModesIndex me, pMode
  37.   set Lmax to getProp(iMaxItems, pMode)
  38.   repeat with i = 1 to Lmax
  39.     setAt(mGetEntireMode(me, pMode), i, 0)
  40.   end repeat
  41. end
  42.  
  43. on mClearModesIndex me
  44.   mClearThisModesIndex(me, gModeState)
  45. end
  46.  
  47. on mGetThisEntryName me, pMode, pItem, pLocalItem
  48.   return getPropAt(mGetModesAttribGroup(me, pMode, pItem), value(pLocalItem))
  49. end
  50.  
  51. on mGetThisEntrysAttribs me, pMode, pItem, pLocalItem
  52.   set vgroup to mGetModesAttribGroup(me, pMode, pItem)
  53.   if vgroup = 0 then
  54.     abort()
  55.   end if
  56.   return getAt(vgroup, pLocalItem)
  57. end
  58.  
  59. on mFindThisNtrysAttribs me, pMode, pItem, pName
  60.   set gCurrentEntryName to pName
  61.   mRequestAnyAttrList(me, pItem, pMode)
  62.   set LmyAttribs to getaProp(mGetModesAttribGroup(me, pMode, pItem), pName)
  63.   if not voidp(LmyAttribs) then
  64.     return LmyAttribs
  65.   else
  66.     hputmsg("TRYING EXTRA SPACE IN NAME")
  67.     set LmyAttribs to getaProp(mGetModesAttribGroup(me, pMode, pItem), pName & " ")
  68.     if not voidp(LmyAttribs) then
  69.       return LmyAttribs
  70.     else
  71.       hputmsg("!mFindThisNtrysAttribs couldnt match" && pName)
  72.       return 
  73.     end if
  74.   end if
  75. end
  76.  
  77. on mSetSingleList me, pWithThisList
  78.   if not objectp(pWithThisList) then
  79.     return 0
  80.   end if
  81.   set Lsize to count(pWithThisList)
  82.   hReportStatus("Building lookup map for " & Lsize & " entries found containing that word.")
  83.   set iCurrentPointList to [Lsize]
  84.   setAt(mGetEntireMode(me, gModeState), 1, pWithThisList)
  85.   mSetCurrItem(me, 1)
  86.   mPrepCurrentLU(oSLlookup)
  87.   return 1
  88. end
  89.  
  90. on mUpdateIndexParams me
  91.   set iCurrentPointList to getaProp(iSizeIndex, gModeState)
  92.   if gModeState = #CHRO then
  93.     mSetCurrItem(me, gFirstYearK)
  94.   else
  95.     mSetCurrItem(me, 1)
  96.   end if
  97. end
  98.  
  99. on mUpdateLimitsList me, pMode, pSize
  100.   if pMode = #FoundSet then
  101.     setaProp(iLimitsList, pMode, pSize)
  102.     setaProp(iSizeIndex, pMode, pSize)
  103.   else
  104.     setaProp(iLimitsList, pMode, count(mGrabCurrAttrList(me, pMode)))
  105.   end if
  106. end
  107.  
  108. on mSetCurrAttrList me, pThisField, pMode
  109.   if hIsaCastMem(pThisField) then
  110.     set LthisItem to hExtractAlphaItem(pThisField)
  111.     if not objectp(mGetModesAttribGroup(me, pMode, LthisItem)) then
  112.       hReportStatus("Loading new index...")
  113.       setAt(mGetEntireMode(me, pMode), LthisItem, value(field pThisField))
  114.       hSetAlphaState(hConvertItemtoAlpha(LthisItem))
  115.     end if
  116.   else
  117.     hReportStatus("Sorry, having trouble decoding that entry name.")
  118.     hearit(gNopeSND)
  119.     abort()
  120.   end if
  121.   if not objectp(iMasterIndex) then
  122.     hputmsg("!>mSetCurrAttrList couldn't create item" & LthisItem & "of iMasterIndex from field >" & pThisField & "<")
  123.     return 0
  124.   end if
  125.   set iCurrentPointList to getaProp(iSizeIndex, pMode)
  126.   mSetCurrItem(me, LthisItem)
  127.   mGetIndexData(oIndexScroller)
  128.   return 1
  129. end
  130.  
  131. on mGrabCurrItem me
  132.   return iCurrentItem
  133. end
  134.  
  135. on mGetEntireMode me, pMode
  136.   return getaProp(iMasterIndex, pMode)
  137. end
  138.  
  139. on mDumpMasterIndex me, pMode
  140.   if pMode = #ALL then
  141.     return iMasterIndex
  142.   else
  143.     return getaProp(iMasterIndex, pMode)
  144.   end if
  145. end
  146.  
  147. on mGetModesAttribGroup me, pMode, pItem
  148.   if (pItem > 26) or (pItem < 1) then
  149.     abort()
  150.   end if
  151.   if (pMode = #FoundSet) or (pMode = #TOPICS) then
  152.     set pItem to 1
  153.   end if
  154.   set Lgroup to getAt(mGetEntireMode(me, pMode), value(pItem))
  155.   if not objectp(Lgroup) then
  156.     mLoadAnyAttrList(me, pItem, pMode)
  157.     return getAt(mGetEntireMode(me, pMode), value(pItem))
  158.   else
  159.     return Lgroup
  160.   end if
  161. end
  162.  
  163. on mGrabCurrAttrList me, pMode
  164.   return mGetModesAttribGroup(me, pMode, iCurrentItem)
  165. end
  166.  
  167. on mRequestAnyAttrList me, pWhatItemNum, pMode
  168.   if not objectp(mGetModesAttribGroup(me, pMode, pWhatItemNum)) then
  169.     mLoadAnyAttrList(me, pWhatItemNum, pMode)
  170.   end if
  171. end
  172.  
  173. on mLoadAnyAttrList me, pWhatItemNum, pMode
  174.   put "Loading more index data..." into field "Status"
  175.   set Lthisfield to hConstructFieldName(pWhatItemNum, pMode)
  176.   if hIsaCastMem(Lthisfield) then
  177.     setAt(mGetEntireMode(me, pMode), pWhatItemNum, value(field Lthisfield))
  178.   else
  179.     if Lthisfield = "ATTRIB_R_CHRO" then
  180.       set Lthisfield to "ATTRIB_18_CHRO"
  181.       setAt(mGetEntireMode(me, pMode), pWhatItemNum, value(field Lthisfield))
  182.       exit
  183.     end if
  184.     hearit(gNopeSND)
  185.     return 
  186.   end if
  187. end
  188.  
  189. on mSetCurrItem me, pWhat
  190.   if gModeState = #FoundSet then
  191.     set pWhat to 1
  192.   end if
  193.   if (pWhat < 1) or (pWhat > getProp(iMaxItems, gModeState)) then
  194.     abort()
  195.   end if
  196.   set iCurrentItem to pWhat
  197.   hSetAlphaState(hConvertItemtoAlpha(value(pWhat)))
  198. end
  199.  
  200. on mIsWithinCurrentList me, pWhatCount
  201.   return hGetMyAlphaGroupItem(pWhatCount) / (iCurrentItem * 1.0)
  202. end
  203.  
  204. on mGetItemsFirstEntryNum me, pWhatItem
  205.   if pWhatItem = 1 then
  206.     return 1
  207.   end if
  208.   set Lvalue to getAt(iCurrentPointList, pWhatItem - 1) + 1
  209.   return Lvalue
  210. end
  211.  
  212. on mGetMyLastEntryNum me, pWhatAlpha
  213.   if gModeState = #FoundSet then
  214.     set Litem to 1
  215.   else
  216.     set Litem to hConvertAlphaToItem(pWhatAlpha)
  217.   end if
  218.   set Lmyvalue to getAt(iCurrentPointList, Litem)
  219.   return Lmyvalue
  220. end
  221.  
  222. on mGetPrevLastEntryNum me, pWhatAlpha
  223.   set Lprevitem to hConvertAlphaToItem(hSubtractOnefromMe(pWhatAlpha))
  224.   set Lmyvalue to getAt(iCurrentPointList, Lprevitem)
  225.   return Lmyvalue
  226. end
  227.  
  228. on mGetThisItemsMax me, pWhat
  229.   return getAt(iCurrentPointList, pWhat)
  230. end
  231.  
  232. on mGetMyFirstGroupLimit me
  233.   return getAt(iCurrentPointList, mGetMyFirstItem(me))
  234. end
  235.  
  236. on mGetMyMaxItems me
  237.   return getaProp(iMaxItems, gModeState)
  238. end
  239.  
  240. on mGetMyFirstItem me
  241.   if gModeState = #CHRO then
  242.     set Lfirstitem to gFirstYearK
  243.   else
  244.     set Lfirstitem to 1
  245.   end if
  246.   return Lfirstitem
  247. end
  248.  
  249. on mGetModesMaxEntryNum me
  250.   return getaProp(iLimitsList, gModeState)
  251. end
  252.  
  253. on mGetAnyMaxEntryNum me, pMode
  254.   return getaProp(iLimitsList, pMode)
  255. end
  256.  
  257. on mUpdateGlobalFromLocal me
  258.   if iCurrentItem = 1 then
  259.     hSetGlobalCounter(gLocalStepCount)
  260.   else
  261.     hSetGlobalCounter(gLocalStepCount + getAt(iCurrentPointList, iCurrentItem - 1))
  262.   end if
  263. end
  264.  
  265. on mConvertGlobaltoLocal me
  266.   if gModeState = #FoundSet then
  267.     set pWhat to 1
  268.   else
  269.     set pWhat to hGetMyAlphaGroupItem(gGlobalStepCount)
  270.   end if
  271.   mSetCurrItem(me, pWhat)
  272.   if iCurrentItem = 1 then
  273.     hSetLocalCounter(gGlobalStepCount)
  274.   else
  275.     hSetLocalCounter(gGlobalStepCount - getAt(iCurrentPointList, iCurrentItem - 1))
  276.   end if
  277. end
  278.  
  279. on mTranslateGlobaltoLocal me, pSomeGlobal, pItsItem
  280.   if pItsItem = 1 then
  281.     return pSomeGlobal
  282.   else
  283.     return pSomeGlobal - getAt(iCurrentPointList, pItsItem - 1)
  284.   end if
  285. end
  286.  
  287. on mTranslateLocaltoGlobal me, pSomeLocal
  288.   if iCurrentItem = 1 then
  289.     return pSomeLocal
  290.   else
  291.     return pSomeLocal + getAt(iCurrentPointList, iCurrentItem - 1)
  292.   end if
  293. end
  294.  
  295. on mComputeModesLastEntryNum me, pMode
  296.   set Lmaxitem to count(getaProp(iSizeIndex, pMode))
  297.   if not voidp(Lmaxitem) then
  298.     set Llist to []
  299.     set Llist to getaProp(iSizeIndex, pMode)
  300.     return getAt(Llist, Lmaxitem)
  301.   else
  302.   end if
  303. end
  304.  
  305. on mDumpProps me
  306.   put me
  307.   put "iCurrentPointList=", iCurrentPointList
  308.   put "iCurrentItem=", iCurrentItem
  309.   put "iLimitsList=" & iLimitsList
  310.   put "iMaxItems=" & iMaxItems
  311.   put "size of iSizeIndex=" & count(iSizeIndex)
  312. end
  313.  
  314. on mDumpCurrPts me
  315.   put iCurrentPointList
  316.   return iCurrentPointList
  317. end
  318.  
  319. on mDumpLimits me
  320.   put iLimitsList
  321. end
  322.  
  323. on mUpdateTopicIndex me
  324.   global oIndexScroller
  325.   mClearThisModesIndex(me, #TOPICS)
  326.   setProp(iLimitsList, #TOPICS, mGetSingleModeSize(me, #TOPICS))
  327.   mLoadAnyAttrList(me, 1, #TOPICS)
  328. end
  329.